/*
This cross-browser DOM routine uses feature-sensing to determine 
which DOM type is being used, and then a function to define the DOM
for a particular object based on that information
*/

// Define global variables
var isDHTML = 0; 	// the browser supports a DOM
var isLayers = 0; 	// Netscape Layer DOM (NN4)
var isAll = 0; 		// Internet Explorer All DOM (IE4)
var isID = 0;		// WC3 ID DOM (IE5+, NN5+)

//global variables containing true or false depending on the browser.
var ns = (navigator.appName.indexOf('Netscape')>-1);
var ie = (navigator.appName.indexOf('Microsoft Internet Explorer')>-1);


// Set the variables
// Note that feature sensing  doesn't work to detect 
// the Netscape Layer DOM when the code is in a separate file

if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
	if (document.all) {isAll = 1; isDHTML = 1;}
	else {
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
			isLayers = 1; isDHTML= 1;
		}
	}
}


// Function to access the DOM correctly
// It takes the ID for the desired object and accesses the DOM depending 
// on the version being used by the browser
// This version of the code takes 2 object IDs (parent and child) to accommodate nested CSS layers for Netscape 4 
// (for IE or other NS versions, only the child ID is necessary (even thought both will be supplied)). 
// If there is no nesting the parentObjectID will be null.
// Depending on the withStyle parameter, it access the style or the other 
// properties associated with the object.

function AccessDOM(parentObjectID, childObjectID, withStyle) {
	if (withStyle == 1) {
		if (isID) {return (document.getElementById(childObjectID).style);}	//W3C DOM Netscape 6 and IE 5+
		else {
			if (isAll) {return (document.all[childObjectID].style);}		//IE 4 and 5 All DOM
			else {
				if (isLayers) {
					if (parentObjectID) {									//Netscape 4 Layer DOM
						return (document.layers[parentObjectID].layers[childObjectID]);	//nested layers
					}
					else {
						return (document.layers[childObjectID]);
					}
				}
			}
		}
	}
	else {
		if (isID) {return (document.getElementById(childObjectID));}		//W3C DOM Netscape 6 and IE 5+
		else {
			if (isALL) {return(document.all[childObjectID]);}				//IE 4 and 5 All DOM
			else {
				if (isLayers) {
					if (parentObjectID) {									//Netscape 4 Layer DOM
						return (document.layers[parentObjectID].layers[childObjectID]);	//nested layers
					}
					else {
						return (document.layers[childObjectID]);
					}
				}
			}
		}
	}
}



	
